"""
Example job for the process pool
"""

from twisted.application.service import IServiceMaker
#from twisted.application import internet
from twisted.plugin import IPlugin
from twisted.python import usage
from zope.interface import implements

from fjork import ifjork
#from fjork import pool
#from fjork import protocols
from fjork import server

class Options(usage.Options):
    optParameters = [["port", "p", None, "The port number to listen on."]]

class FjorkServiceMaker(object):
    implements(IPlugin, IServiceMaker, ifjork.IFjorkService)
    tapname = "fjork"
    description = "Fjork Service"
    options = Options

    def makeService(self, options):
        """
        Construct a TCPServer from a factory defined in myproject.
        """
        from fjork import settings
        settings.load()
        port = options["port"]
        if port is None:
            port = settings.PORT
        port = int(port)
        return server.FjorkServer(port)


fjork = FjorkServiceMaker()
